<?php
$pagename="Patron Info";
Require_Once("auth.php");
include "connect.php";
include "header.php";

$patroncode=$_GET['code'];
$sql_select = "SELECT * FROM patrons WHERE code = '$patroncode'";
$fetch = mysql_query($sql_select);
$book_fetch = mysql_fetch_array($fetch);
$fname=$book_fetch['fname'];
$lname=$book_fetch['lname'];
$result = mysql_query("SELECT author FROM books WHERE outto='$patroncode'");
$numout = mysql_num_rows($result);
?>
<Center><h2>Patron Info on <? echo $lname.', '.$fname;?></h2></center><br>

Name: <b><? echo $lname.', '.$fname;?></b><br>
Barcode: <b><?echo $patroncode;?></b><br>
Total Fines: <b><?echo $book_fetch['fines'];?></b><br>
<h3>Books Out:</h3>
<?php

$sql = mysql_query("select * from books where outto like '$patroncode'");
$num_rows = mysql_num_rows($sql);
while ($row = mysql_fetch_array($sql)){
	$code = $row['barcode'];
	$duedate= $row['duedate'] + 1209600;
	$test=$duedate < time();
	echo $test;
	echo '</b><br/> Book:<b>'.$row['name'];
	echo '</b><br/> Barcode: <b>'.$row['barcode'];
    echo '</b><br/> Due On <b>'.date('Y-m-d', $duedate);
$test=$duedate > time();

	echo '<br>';
	echo '<br>';
	}
	?>